Type.registerNamespace("Telerik.Web.UI");
Telerik.Web.UI.RadDockZonesGlobalArray=[];
Telerik.Web.UI.registerRadDockZone=function(a){if(!Array.contains(this.RadDockZonesGlobalArray,a)){Array.add(this.RadDockZonesGlobalArray,a);
}};
Telerik.Web.UI.unregisterRadDockZone=function(a){Array.remove(this.RadDockZonesGlobalArray,a);
};
Telerik.Web.UI.RadDockZone=function(a){Telerik.Web.UI.RadDockZone.initializeBase(this,[a]);
this._clientID=null;
this._highlightedCssClass=null;
this._fitDocks=true;
this._uniqueName=null;
this._layoutID=null;
};
Telerik.Web.UI.RadDockZone.prototype={initialize:function(){Telerik.Web.UI.RadDockZone.callBaseMethod(this,"initialize");
this._resetDockIndices();
this._placeholder=$get(this.get_clientID()+"_D");
if($telerik.isRightToLeft(this.get_element())){Sys.UI.DomElement.addCssClass(this._placeholder,"rdRtl");
}this._clearElement=$get(this.get_clientID()+"_C");
Telerik.Web.UI.registerRadDockZone(this);
},dispose:function(){Telerik.Web.UI.unregisterRadDockZone(this);
Telerik.Web.UI.RadDockZone.callBaseMethod(this,"dispose");
},dock:function(c,d){var b=this.get_docks();
var a=null;
if(b.length>d){a=b[d].get_element();
}this._dockBefore(c,a,false);
},get_docks:function(){var c=[];
var b=this.get_element().firstChild;
while(b!=null){if(b!=this._placeholder&&b.id){var a=$find(b.id);
if(a&&Telerik.Web.UI.RadDock&&Telerik.Web.UI.RadDock.isInstanceOfType(a)){Array.add(c,a);
}}b=b.nextSibling;
}return c;
},_dockBefore:function(l,c,a,d){d=d?d:false;
var j=l.get_element();
var k=this.get_element();
var f=l.get_enableAnimation()?l.get_animationDuration():0;
var b={};
var i;
if(c){if(c!=this._placeholder){k.insertBefore(this._placeholder,c);
c=this._placeholder;
}i=c;
i.style.display="";
var m=$telerik.getLocation(i);
var h=$telerik.getBounds(i);
b.left=m.x;
b.top=m.y;
b.width=h.width;
}else{i=this._clearElement;
f=0;
}var g=l.get_titleElement();
if(g!=null){g.style.display="none";
}if(!d||f==0){this._onDockBeforeAnimationEnd(l,i,a);
return;
}var e=this;
$telerik.$(j).animate(b,f,function(){e._onDockBeforeAnimationEnd(l,i,a);
});
},_onDockBeforeAnimationEnd:function(f,g,b){var e=f.get_element();
var d=this.get_element();
if(g){if(g.className.indexOf("rdPlaceHolder")!=-1){g.style.display="none";
}}var c=f.get_titleElement();
if(c!=null){c.style.display="block";
}if(f._closed){e.style.display="none";
}d.insertBefore(e,g);
var a=$find(f.get_dockZoneID());
if(a){a._resetDockIndices();
}f.set_dockZone(this);
f.set_dockZoneID(d.id);
if(this.get_fitDocks()){if(!this.get_isHorizontal()){f._fitWidth();
}}else{if(!this.get_isHorizontal()){f._unfitWidth();
}}f._resetPosition();
f._setPinUnpinVisibility();
this._resetDockIndices();
if(b){f.raise_dockPositionChanged(new Sys.EventArgs());
}},_resetDockIndices:function(){var b=this.get_docks();
for(var a=0;
a<b.length;
a++){b[a].set_index(a);
b[a].updateClientState();
}},get_isHorizontal:function(){return Sys.UI.DomElement.containsCssClass(this.get_element(),"rdHorizontal");
},_lastFoundItem:null,_lastFoundItemBounds:null,_findItemAt:function(a,f){var d=this.get_element();
if(!(this._lastFoundItem&&this._isInside(a,this._lastFoundItemBounds))){this._lastFoundItem=null;
this._lastFoundItemBounds=null;
var j=d.firstChild;
while(j!=null){if(j!=f&&j.nodeType!=3&&j.nodeType!=8){var b=this.get_isHorizontal();
var h=this._getMarginBox(f);
var c=this._getBorderBox(f);
var e=$telerik.getBounds(j);
var g=$telerik.getLocation(j);
e.x=g.x;
e.y=g.y;
e.x-=(($telerik.isSafari?0:h.left)+c.left+2);
e.y-=(h.top+c.top+2);
e.width+=(($telerik.isSafari?0:h.right)+c.right+2);
e.height+=(h.bottom+c.bottom+2);
var i={x:e.x,y:e.y,width:(b?e.width/2:e.width),height:(b?e.height:e.height/2)};
if(this._isInside(a,i)){this._lastFoundItem=j;
this._lastFoundItemBounds=i;
break;
}var k={x:e.x+(b?e.width/2:0),y:e.y+(b?0:e.height/2),width:(b?e.width/2:e.width),height:(b?e.height:e.height/2)};
if(this._isInside(a,k)){if(j.nextSibling){this._lastFoundItem=j.nextSibling;
this._lastFoundItemBounds=k;
break;
}}}j=j.nextSibling;
}}return this._lastFoundItem;
},_isInside:function(b,a){return(b.x>a.x&&b.x<(a.x+a.width)&&b.y>a.y&&b.y<(a.y+a.height));
},_showPlaceholder:function(e,d){this._repositionPlaceholder(e.get_element(),d);
var c=this.get_docks();
if(c.length>0){for(var a=0;
a<c.length;
a++){if(c[a].get_closed()==false){var f=e._getBounds();
var h=e._getMarginBox(this._placeholder);
var b=e._getBorderBox(this._placeholder);
var g=this.get_isHorizontal();
var j=this._placeholder.style;
j.height=f.height-(h.vertical+b.vertical)+"px";
j.width=this.get_fitDocks()&&!g?"100%":f.width-(h.horizontal+b.horizontal)+"px";
j.display="block";
return;
}}}if(this.get_highlightedCssClass()==null){Sys.UI.DomElement.addCssClass(this.get_element(),"rdPlaceHolder");
}},_repositionPlaceholder:function(c,b){var d=this._findItemAt(b,c);
var a=this.get_element();
if(null==d){a.insertBefore(this._placeholder,this._clearElement);
}else{if(d.previousSibling!=this._placeholder){a.insertBefore(this._placeholder,d);
}}},_getMarginBox:function(a){return $telerik.getMarginBox(a);
},_getBorderBox:function(a){return $telerik.getBorderBox(a);
},_hidePlaceholder:function(){Sys.UI.DomElement.removeCssClass(this.get_element(),"rdPlaceHolder");
this._placeholder.style.display="none";
this._lastFoundItem=null;
this._lastFoundItemBounds=null;
},hidePlaceholder:function(){this._hidePlaceholder();
},canDrop:function(a){return((a.get_dockMode()&Telerik.Web.UI.DockMode.Docked)>0&&Array.indexOf(a.get_forbiddenZones(),this.get_uniqueName())<0);
},drop:function(a){var b=new Sys.CancelEventArgs();
a.raise_dockPositionChanging(b);
this._hidePlaceholder();
if(this.get_highlightedCssClass()!=null){this.removeCssClass(this.get_highlightedCssClass());
}if(b.get_cancel()){a._restorePosition();
}else{this._dockBefore(a,this._placeholder,true,true);
}},dragEnterTarget:function(a,b){this._showPlaceholder(a,b);
if(this.get_highlightedCssClass()!=null){this.addCssClass(this.get_highlightedCssClass());
}},onDragInTarget:function(a,b){this._repositionPlaceholder(a.get_element(),b);
},dragLeaveTarget:function(a){this._hidePlaceholder();
if(this.get_highlightedCssClass()!=null){this.removeCssClass(this.get_highlightedCssClass());
}},pointInZone:function(a){return $telerik.isMouseOverElement(this.get_element(),a);
},hitTest:function(a,d,c){if(!this.canDrop(a)){return false;
}if(c==null){c=true;
}if(this.pointInZone(d)){if(c){var b=$telerik.getDocumentRelativeCursorPosition(d);
loc={x:b.left,y:b.top};
this.dragEnterTarget(a,loc);
}return true;
}else{this.dragLeaveTarget(a);
return false;
}},getScrollOffset:function(d,e){var c=d.scrollLeft;
var a=d.scrollTop;
if(e){var b=d.parentNode;
while(b!=null&&b.scrollLeft!=null){c+=b.scrollLeft;
a+=b.scrollTop;
if(b==document.body&&(c!=0&&a!=0)){break;
}b=b.parentNode;
}}return{x:c,y:a};
},clone:function(f){if(!f){f="RadDockZoneClone_"+(new Date()-100);
}var e=this.get_element();
var c=e.cloneNode(true);
c.setAttribute("id",f);
c.removeAttribute("control");
c.innerHTML="";
var d=this._placeholder.cloneNode(true);
d.setAttribute("id",f+"_D");
c.appendChild(d);
var b=$get(this._clientStateFieldID).cloneNode(true);
b.setAttribute("id",f+"_ClientState");
c.appendChild(b);
var g;
if(this._clearElement){g=this._clearElement.cloneNode(true);
g.setAttribute("id",f+"_C");
c.appendChild(g);
}e.parentNode.insertBefore(c,e.nextSibling);
var a=$telerik.cloneControl(this,Telerik.Web.UI.RadDockZone,c);
a._uniqueName=f;
a._placeholder=d;
if(g){a._clearElement=g;
}return a;
},addPoints:function(b,a){return{x:b.x+a.x,y:b.y+a.y};
},get_clientID:function(){return this._clientID;
},set_clientID:function(a){this._clientID=a;
},get_fitDocks:function(){return this._fitDocks;
},set_fitDocks:function(a){this._fitDocks=a;
},get_highlightedCssClass:function(){return this._highlightedCssClass;
},set_highlightedCssClass:function(a){this._highlightedCssClass=a;
},get_layoutID:function(){return this._layoutID;
},set_layoutID:function(a){this._layoutID=a;
},get_uniqueName:function(){return this._uniqueName;
},set_uniqueName:function(a){this._uniqueName=a;
}};
Telerik.Web.UI.RadDockZone.registerClass("Telerik.Web.UI.RadDockZone",Telerik.Web.UI.RadWebControl);
